package MaintMenu.PoAnalysis;

import java.sql.*;
import java.text.NumberFormat;

/**
 * Created with IntelliJ IDEA.
 * User: Jason
 * Date: 8/5/13
 * Time: 4:23 PM
 * To change this template use File | Settings | File Templates.
 */
public class LLP {
    public double LLP(String partnum){
        double lpp=0.00D;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            //Connection to Hicksville
            String dataSourceName = "dbLI";
            String dbURL = "jdbc:odbc:" + dataSourceName;
            Connection connection = DriverManager.getConnection(dbURL, "", "");
            Statement stmt1 = connection.createStatement();
//            Statement stmt1 = connection.createStatement();

            String selecSta1 ="SELECT * FROM tblinventory where [Part#]='"+partnum+"'";
//                String selecSta ="SELECT * FROM "+tbl+"";
//            System.out.println("Statement :"+selecSta);
            stmt1.execute(selecSta1);

            ResultSet resultSet1 = stmt1.getResultSet();

            int rowupd =0;
//                System.out.println("2");
//                System.out.println(resultSet.getRow());

            if (resultSet1 != null)  {


                while (resultSet1.next()) {
                    rowupd++;
                    lpp= resultSet1.getDouble("LPP");




//                    System.out.println("LPP for "+partnum+" is :"+lpp);

                }
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (SQLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }//System.out.println("LPP for "+partnum+" is :"+lpp);
//        System.out.println("return");
        return lpp;
    }
}
